package com.settlement.system.model.param;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.settlement.system.common.enums.RpaChargeTaskStatusEnum;
import io.swagger.annotations.ApiModelProperty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.NotBlank;

import java.math.BigDecimal;
import java.util.Date;

/**
 * FMS 收退，退款报表请求参数
 *
 * @author Ximi
 * @since 2020/08/12
 */
@Data
public class RpaChargeTaskUpdateApiRequestParams extends ApiParams {

    /**
     * 流程requestID
     */
    @ApiModelProperty(value = "流程requestID",required = true)
    @NotBlank(message = "流程requestID不能为空")
    private String processRequestId;

    /**
     * 明细序号ID
     */
    @ApiModelProperty(value = "明细序号ID",required = true)
    @NotBlank(message = "明细序号ID不能为空")
    private String detailNumberId;

    /**
     * OA归档日期
     */
    @ApiModelProperty(value = "OA归档日期",required = true)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @NotNull(message = "OA归档日期不能为空")
    private Date oaArchiveDate;

    /**
     * 任务状态 任务状态: 0:未支付, 1:RPA充值成功, 2:RPA充值失败
     */
    @ApiModelProperty(value = "任务状态")
    @NotBlank(message = "任务状态不能为空")
    private String taskStatus;

    /**
     * 付款金额
     */
    @ApiModelProperty(value = "付款金额")
    private BigDecimal payAmount;

    /**
     * 付款时间
     */
    @ApiModelProperty(value = "付款时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date lastPayTime;

    /**
     * 银行订单号
     */
    @ApiModelProperty(value = "银行订单号")
    private String bankOrder;

    /**
     * 平台交易流水号
     */
    @ApiModelProperty(value = "平台交易流水号")
    private String transactionNumber;

    @Override
    public String verifyBean(){

        if(RpaChargeTaskStatusEnum.RPA_RECHARGE_SUCCESS.getNo().equals(taskStatus)){
            if(null == payAmount
                    ||lastPayTime == null
                    ||StringUtils.isEmpty(bankOrder)
                    ){
                return "当taskStatus="+RpaChargeTaskStatusEnum.RPA_RECHARGE_SUCCESS.getNo()+"时，" +
                        "字段 payAmount、lastPayTime、bankOrder 不能为空";
            }
        }

        return null;
    }

}
